package com.qf.hospital.controller;

import com.qf.hospital.entity.SysUser;
import com.qf.hospital.service.SysUserService;
import com.qf.hospital.vo.R;
import com.qf.hospital.vo.SideVO;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.Callable;

/**
 * @author ASUS
 * @version V1.0
 * @Project hospital
 * @Package com.qf.hospital.controller
 * @Date 2021/10/15 21:03
 */
@RestController
public class SideController {

    private Logger log = LoggerFactory.getLogger(SideController.class);

    @Autowired
    private SysUserService sysUserService;

    @GetMapping("/side")
    public List<SideVO> side(){
        Subject subject = SecurityUtils.getSubject();
        SysUser sysUser = (SysUser) subject.getPrincipal();
        if (sysUser == null){
            log.info("【侧边栏】用户已经登录超时");
            return null;
        }
        System.out.println(sysUser.getUserId());
        List<SideVO> list = sysUserService.findMenuByUserId(sysUser.getUserId());
        System.out.println(list);
        return list;
    }
}
